﻿using XServer.Models.Sys;

namespace XServer.Managers
{
    public class UserManager
    {
        private IDictionary<string, User> _users = new Dictionary<string, User>();

        public void RegistUser(string uid)
        {
            User user = new User();
            user.Id = uid;
            user.currency = 1000;
            AddUser(user);
        }

        public bool AddUser(User user)
        {
            if (_users.ContainsKey(user.Id))
            {
                return false;
            }

            _users.Add(user.Id, user);
            return true;
        }

        public User? GetUser(string uid)
        {
            if (!_users.ContainsKey(uid))
            {
                return null;
            }

            return _users[uid];
        }

        public bool DeleteUser(string uid)
        {
            if (!_users.ContainsKey(uid))
            {
                return false;
            }
            return _users.Remove(uid);
        }
    }
}
